package com.elkovacho.view.components
{
	import com.greensock.TweenMax;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;
	
	import org.hamcrest.object.nullValue;
	
	public class CustomMouseCursor extends Sprite
	{
		
		private var _alpha:Number;
		private var _face:Sprite;
		private var _radius:uint;
		private var _color:uint;
		private var _maxRadius:uint;
		private var _clickEffectTime:Number;
		
		public function CustomMouseCursor()
		{
			//TODO: config param!!!
			_radius = 30;
			_maxRadius = 60;
			_color = 0xFF0000;
			_clickEffectTime = .5;
			_alpha = .85;
		}
		
		private function init():void
		{
			Mouse.hide();
			drawFace();
		}
		
		private function drawFace():void
		{
			_face = new Sprite();
			_face.graphics.beginFill(_color, _alpha);
			_face.graphics.drawCircle(0, 0, _radius);
			_face.graphics.endFill();
			addChild(_face);
		}
			
		public function updatePosition(e:MouseEvent):void
		{
			if (_face == null) init();
			
			_face.x = e.stageX;
			_face.y = e.stageY;
		}
		
		public function click():void
		{
			Mouse.show();
			
			TweenMax.to(_face, _clickEffectTime, {width: width + _maxRadius, height: height + _maxRadius});
		}
		
	}
}